#!/usr/bin/perl -w
use strict;

cd ~/project/cell_wall/merk/working 
for file in *.fas
do
 filebase=`basename $file .fas`
 echo "Processing file: $file"
 /usr/local/bin/t_coffee $file
 /usr/local/bin/bp_sreformat.pl -if clustalw -of fasta -i $base.aln -o $base.fasaln
 hmmbuild -F $filebase.hmm $base.fasaln
 hmmcalibrate $filebase.hmm


 for db in /home/dsain/project/cell_wall/db/*.fa
 do
  dbbase=`basename $db .pep.fa`
  hmmsearch -E 1e-3 $base.hmm $db > $filebase_vs_$dbbase.hmmsearch
  /usr/local/bin/bp_hmmer_to_table.pl $filebase_vs_$dbbase.hmmsearch > $filebase_vs_$dbbase.hmmsearch.tab
  # extract the full sequences back out
  perl $HOME/projects/stajichlab/labcode/cell_wall/scripts/extract_seqs_from_table.pl -db /home/dsain/project/cell_wall/db -c 1e-1 $filebase_vs_$dbbase.hmmsearch.tab >  
$filebase_vs_$dbbase.hmmsearch.fas
  #
 done 
done

# end running perl script
hmmalign -q --outformat=clustal $base.hmm $base_allseq.fas > $base_allseq.hmmalign
/usr/local/bin/bp_sreformat.pl -if clustalw -of phylip -i $base_allseq.hmmalign -o $base_all.hmmalign.phy --special="idlength=20"
~jstajich/bin/raxmlHPC-PTHREADS -T 8 -N 100 -f a -s $base_all.hmmalign.phy -n $base_all.hmmalign -m PROTMIXWAG -x 121
